package com.ruoyi.project.keshi.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.keshi.domain.SysCheckfee;
import com.ruoyi.project.keshi.service.ISysCheckfeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 检查费用Controller
 *
 * @author ruoyi
 * @date 2021-09-12
 */
@RestController
@RequestMapping("/keshi/checkfee")
public class SysCheckfeeController extends BaseController
{
    @Autowired
    private ISysCheckfeeService sysCheckfeeService;

    /**
     * 查询检查费用列表
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCheckfee sysCheckfee)
    {
        startPage();
        List<SysCheckfee> list = sysCheckfeeService.selectSysCheckfeeList(sysCheckfee);
        return getDataTable(list);
    }

    /**
     * 导出检查费用列表
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:export')")
    @Log(title = "检查费用", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysCheckfee sysCheckfee)
    {
        List<SysCheckfee> list = sysCheckfeeService.selectSysCheckfeeList(sysCheckfee);
        ExcelUtil<SysCheckfee> util = new ExcelUtil<SysCheckfee>(SysCheckfee.class);
        return util.exportExcel(list, "checkfee");
    }

    /**
     * 获取检查费用详细信息
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:query')")
    @GetMapping(value = "/{feeId}")
    public AjaxResult getInfo(@PathVariable("feeId") Long feeId)
    {
        return AjaxResult.success(sysCheckfeeService.selectSysCheckfeeById(feeId));
    }

    /**
     * 新增检查费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:add')")
    @Log(title = "检查费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCheckfee sysCheckfee)
    {
        return toAjax(sysCheckfeeService.insertSysCheckfee(sysCheckfee));
    }

    /**
     * 修改检查费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:edit')")
    @Log(title = "检查费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCheckfee sysCheckfee)
    {
        return toAjax(sysCheckfeeService.updateSysCheckfee(sysCheckfee));
    }

    /**
     * 删除检查费用
     */
    @PreAuthorize("@ss.hasPermi('keshi:checkfee:remove')")
    @Log(title = "检查费用", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feeIds}")
    public AjaxResult remove(@PathVariable Long[] feeIds)
    {
        return toAjax(sysCheckfeeService.deleteSysCheckfeeByIds(feeIds));
    }
}
